<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="hmg.common.CommonUtils"%>
<%@ page import="java.util.List"%>
<%@ page import="hmg.vo.ZipVO"%>
<%-- 
    JSP Name : jspName.jsp
    Description : 설명을 기술합니다.
    author Kim hyung soo
    since 2012. 10. 5.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 10. 5.     Kim hyung soo     최초 생성
--%>
<%
    String searchKeyword = CommonUtils.getDecodedParameter(request.getParameter("searchKeyword"), "");

    List<ZipVO> addressList = (List<ZipVO>) request.getAttribute("AddressList");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="ko" xml:lang="ko" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>우편번호찾기 | 현대자동차그룹</title>
<meta name="description" content="현대자동차그룹 우편번호찾기" />
<meta name="keywords" content="현대자동차그룹 우편번호찾기, 현대차그룹 우편번호찾기, 우편번호찾기" />
<link rel="stylesheet" type="text/css" href="/hmg/css/web/kor/com/content.css" />
<link rel="stylesheet" type="text/css" href="/hmg/css/web/kor/com/popup.css" />
<!--[if IE 7]><link rel="stylesheet" type="text/css" href="/hmg/css/web/kor/com/ie7.css" /><![endif]-->
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<script type="text/javascript" src="/hmg/js/web/kor/com/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/hmg/js/web/kor/com/googleAnalytics.js"></script>
<script type="text/javascript">
//<![CDATA[
var searchKeyword = "<%= searchKeyword %>";

function fn_win_close() {
    self.close();
}

function fn_search() {
    var keyword = $("#searchKeyword").val();
    var searchType = $("#searchType").val();
    
    if (keyword == "") {
        alert("검색어를 입력해 주세요.");
        return;
    }
    else if (keyword.length < 2) {
        alert("검색어를 2자 이상 입력해 주세요.");
        return;
    }

    document.location.href = "./AddressSearch.do?searchType=" + searchType + "&searchKeyword=" + escape(encodeURIComponent(keyword));
}

function fn_select_zipcode(zipID, zipCode1, zipCode2, sido, gu, dong) {
    $("#zipID", opener.document).val(zipID);
    $("#zipCode1", opener.document).val(zipCode1);
    $("#zipCode2", opener.document).val(zipCode2);
    $("#address1", opener.document).val(sido + " " + gu + " " + dong);
    
    self.close();
}

//]]>
</script>
</head>
<body class="popup">
    <!--wrap-->
    <div class="popWrap">
        <!-- 내용 -->
        <div class="address_search">
            <h1><img src="/hmg/images/web/kor/grn/address_Search_Title.gif" alt="우편번호 찾기" /></h1>
            <div class="event_layer_BoxWrap">

                <p class="address_text">찾으시는 주소의 <span class="f_bold">읍,면 또는 동 이름</span>을 입력하세요.</p>

                <div class="list_table">
                    <table summary="검색어 입력 테이블">
                        <caption>검색어 입력</caption>
                        <colgroup><col width="30%" /><col width="70%"/></colgroup>
                        <tbody>
                            <tr>
                                <th scope="row">검색어 입력</th>
                                <td>
                                    <input type="text" title="검색어 입력" id="searchKeyword" name="searchKeyword" value="<%= searchKeyword %>" maxlength="50" onkeypress="javascript:if (event.keyCode==13) {fn_search();}"/>
                                    <a href="javascript:fn_search();"><img src="/hmg/images/web/kor/btn/btn_search02.gif" alt="조회" /></a>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>

                <p class="address_text"><span class="f_bold">검색결과</span></p>

                <div class="list_table02">
                    <table summary="검색결과 테이블">
                        <caption>검색결과</caption>
                        <colgroup><col width="30%" /><col width="70%"/></colgroup>
                        <tbody>
                            <tr>
                                <th scope="col">우편번호</th>
                                <th scope="col" class="left">주소</th>
                            </tr>
<%  if (addressList == null || addressList.size() == 0) { %>
                            <tr>
                                <td rowspan="1" colspan="2">검색 결과가 없습니다.</td>
                            </tr>
<%  
    }
    else {
        for (int idx = 0;idx < addressList.size();idx++) {
            ZipVO addr = addressList.get(idx);
%>
                            <tr>
                                <td><%= addr.getZipCode() %></td>
                                <td class="left"><a href="#" onclick="javascript:fn_select_zipcode('<%= addr.getZipID() %>', '<%= addr.getZipCode().substring(0, 3) %>', '<%= addr.getZipCode().substring(4) %>', '<%= addr.getSido() %>', '<%= addr.getGu() %>', '<%= addr.getDong() %>');"><%= addr.getSido() %> <%= addr.getGu() %> <%= addr.getDong() %> 
<%          if (addr.getBeonji() != null) { %>
                                                     <%= addr.getBeonji() %>
<%          } %>
                                                 </a>
                                </td>
                            </tr>
<%  
        }
    }
%>
                        </tbody>
                    </table>
                </div>
            </div>
            <p class="addressClose"><a href="#" onclick="fn_win_close();"><img src="/hmg/images/web/kor/grn/newsLetter_request_Close.gif" alt="닫기"/></a></p>
        </div>
        <!--// 내용 -->
    </div>
    <!--//wrap-->
</body>
</html>